Chapter Overview
The Text Encoding Converter provides conversion between any two text encodings. This involves a combination of the following techniques:
Conversion routines are handled using plug-in components implemented as code fragments. The main export symbol of each fragment is a routine that returns a pointer to a table containing a plug-in signature, table version information, and hooks to each of the plug-ins functions. Each plug-in can be polled for the encodings it supports and is responsible for handling all conversions between its supported encodings. The Text Encoding Converter decides how best to meet a caller's conversion requirements using the conversion resources available to it. A conversion may involve combining several conversions in succession. The caller is shielded from this complexity and treats an encoding converter object as a single entity regardless of its actual structure.
- Table-based conversion to or from Unicode, using the Unicode Converter. A single X-to-Y conversion may involve converting X to Unicode, and then converting Unicode to Y. Intermediate storage for the Unicode form is handled by the Text Encoding Converter.
- Algorithmic conversion, using plug-in code modules. These plug-ins are implemented as code fragments.
- Maintaining and updating the current state (the current encoding and other relevant information) for multiple-encoding streams. It also handles detecting escape sequences, special control characters, and any other tags that change the current encoding state. This information is stored in the converter object and maintained by the plug-ins performing the conversion.
When using the Text Encoding Converter, an application does not need to be aware of the plug-ins available. Each of the converter objects that returns information about the available text encoding conversion services polls all plug-ins and makes them appear as one large plug-in.